home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
MacWorld 1999 January - Disc 2
/
Macworld (1999-01) (Disk 2).dmg
/
Serious Demos
/
Portfolio 4.0.1
/
Scripting Extras
/
Move DCS Plates.txt
< prev
next >
Wrap
Text File
|
1998-09-15
|
3KB
|
74 lines
-- 1.01 - Check to make sure Portfolio is running
tell application "Finder"
set P_app to every process whose name contains "Portfolio"
if P_app is {} then
display dialog ¬
"Portfolio must be running for this script to operate." buttons {"OK"} default button {"OK"}
return
end if
end tell
set countMoved to 0
tell application "Portfolio"
-- Go to Portfolio and find out how many items are selected in the current gallery.
set theCount to count every record of selection of front gallery
-- If no items are selected, we need to ask the user to select something and then quit.
if theCount = 0 then
display dialog ¬
"Please select one or more items in the gallery and rerun the command." buttons {"OK"} default button {"OK"}
return
end if
-- Get the first record of the selection. We'll ignore the rest.
set fName to field "path" of first record of the selection of front gallery
end tell
-- Parse Portfolio's path if it is up on a server to strip the server name.
if fName starts with "::" then
set the text item delimiters to {":"}
set argCnt to (the count of text items in fName)
set fName to (text items 4 through argCnt in (fName)) as string
end if
--Get the destination folder
set newFolder to choose folder with prompt "Select the destination folder:"
-- Figure out if the original file name has an extension
set text item delimiters to "."
set lParsed to every text item of fName
if the (count of lParsed) > 1 then
set fRoot to items 1 thru ((count of lParsed) - 1) of lParsed as string
else
set fRoot to lParsed as string
end if
-- Build up a list of the five possible files
set leList to {fName as string, fRoot & ".C", fRoot & ".M", fRoot & ".Y", fRoot & ".K"}
-- Iterate through the list, check if the file exists, and if it does, move it to the new location.
repeat with fFile in leList
set fFile to fFile as string -- Coerce the list item to a string
tell application "Finder"
if (exists of file fFile) then
move file fFile to folder newFolder
set countMoved to countMoved + 1
end if
end tell
end repeat
-- Build the name for the composite file at its new location
set text item delimiters to ":"
set fComposite to the last text item of fName as string
set newPath to (newFolder as string) & fComposite
--Update the Portfolio location for that item
tell application "Portfolio"
set path of first record of the selection of front gallery to newPath
end tell
-- Tell the user the results
display dialog "Results:" & return & countMoved & ¬
" out of 5 files were successfully moved." buttons {"OK"}